const app = getApp()
import {
  HomeIndex
} from 'index-modal.js';
import {
  Config
} from '../../../utils/config.js';
var Function = require("../../../utils/function.js");
var index = new HomeIndex(); //实例化 首页 对象
Page({
  data: {
    url:Config.Url,
    windowWidth:0,
    hideJin:false,
    mote:[]
    
  },
  onLoad: function(options) {
    this.setData({
      windowWidth: app.globalData.windowWidth,
      goods_id: options.goods_id,
      comp_id: options.comp_id,
      jingdu: options.jingdu,
      weidu:options.weidu
    })

    this._getTeach() //获取理疗师

  },

  showModal() {
    this.setData({ hideJin: true })
  },
  hideModal() {
    this.setData({ hideJin: false })
  },
 
  _getTeach(){   //获取对应的理疗师
    let that =this;
    let data = {
      goods_id: that.data.goods_id,
      comp_id: that.data.comp_id,
      uid: wx.getStorageSync("members").id
    }
    index.getTeach(data,(res)=>{
      if(res.code == 200){
        that.setData({
          mote:res.data
        })
      }
    })
  },
  // 收集formid
  add_form: function (form_id){
    let that=this;
    let datas={
      uid: wx.getStorageSync('members').id,
      form_id: form_id
    }
    index.add_form(datas,(res)=>{
      
    })
  },

  raginhao(e){   //取号
    let that=this;
    var eid = e.currentTarget.dataset.id;
    var comp_id = e.currentTarget.dataset.comp_id;
    var goods_id = e.currentTarget.dataset.goods_id;
    let form_id = e.detail.formId;

    if (!wx.getStorageSync('members')) {
      wx.showModal({
        title: '提示',
        content: '你还未授权是否前往授权',
        success(res) {
          if (res.confirm) {
            wx.navigateTo({
              url: '/pages/auth/auth',
            })
          } else if (res.cancel) {
            console.log('用户点击取消')
          }
        }
      })
    } else {
      that.add_form(form_id);
      wx.navigateTo({
        url: '../quhao/quhao?id=' + eid + '&comp_id=' + comp_id + '&goods_id=' + goods_id
      })
    }
    

  }


  
})